import { createSSRApp } from 'vue'
import App from './App'
import store from './store' // store
import { install } from './plugins' // plugins
import './permission' // permission
import { useDict } from '@/utils/dict'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'

// if (typeof window !== 'undefined') {
//   try {
//     const path = window.location.pathname.replace(/\/+/g,'/');
//     if (path === '/login' || path === '/login/') {
//       window.location.replace('/#/pages/pc/login');
//     }
//   } catch(_) {}
// }

export function createApp() {
  const app = createSSRApp(App)
  app.use(store)
  app.use(ElementPlus, {
    locale: zhCn,
  })
  app.config.globalProperties.useDict = useDict
  install(app)
  return {
    app
  }
}
